
/*
*
* */
Rsd.define('Rsd.Faith.reports.DashboardPage', {
    extend: 'Rsd.container.Page',
    xtype:'dashboard-page',
    requires: ['Rsd.control.ListView','Rsd.control.Chart','Rsd.control.Scaler','Rsd.control.Label'],
    height:1500,
    style:{overFlow:'auto'},
    cls: 'x-dashboard',
    overFlow:'auto',
    items:[
        {
            width: '100%',
            height: 135,
            margin: '20 0 10 0',
            layout: 'hbox',
            items: [
                {
                    xtype: 'chart',
                    height: 100,
                    width: '25%',
                    margin: '0 10 0 10',
                    cls: 'x-dashboard-box',
                    label: {
                        xtype:'scaler',
                        width: 150,
                        height: '100%',
                        position:'right',
                        cls:null,
                        margin: '10 10 10 10',
                        style:{backgroundColor:'#fff'},
                        label:{content:'总 额',  position:'top',space:0,style:{lineHeight:'40px'}},
                        color:'rgba(45, 26, 206, 0.9)',
                        unit:'万元',
                        zoom:200,
                        value:'86000.00'
                    }
                },
                {
                    xtype: 'chart',
                    height: 100,
                    width: '25%',
                    margin: '0 10 0 10',
                    cls: 'x-dashboard-box',
                    label: {
                        xtype:'scaler',
                        width: 150,
                        height: '100%',
                        position:'right',
                        cls:null,
                        margin: '10 10 10 10',
                        style:{backgroundColor:'#fff'},
                        label:{content:'交 存',  position:'top',space:0,style:{lineHeight:'40px'}},
                        color:'rgba(45, 26, 206, 0.9)',
                        unit:'万元',
                        zoom:200,
                        value:'76000.00'
                    }
                },
                {
                    xtype: 'chart',
                    height: 100,
                    width: '25%',
                    margin: '0 10 0 10',
                    cls: 'x-dashboard-box',
                    label: {
                        xtype:'scaler',
                        width: 150,
                        height: '100%',
                        position:'right',
                        cls:null,
                        margin: '10 10 10 10',
                        style:{backgroundColor:'#fff'},
                        label:{content:'增 值',  position:'top',space:0,style:{lineHeight:'40px'}},
                        color:'rgba(45, 26, 206, 0.9)',
                        unit:'万元',
                        zoom:200,
                        value:'16000.00'
                    }
                },
                {
                    xtype: 'chart',
                    height: 100,
                    width: '25%',
                    margin: '0 10 0 10',
                    cls: 'x-dashboard-box',
                    label: {
                        xtype:'scaler',
                        width: 150,
                        height: '100%',
                        position:'right',
                        cls:null,
                        margin: '10 10 10 10',
                        style:{backgroundColor:'#fff'},
                        label:{content:'使 用',  position:'top',space:0,style:{lineHeight:'40px'}},
                        color:'rgba(45, 26, 206, 0.9)',
                        unit:'万元',
                        zoom:200,
                        value:'6000.00'
                    }
                }
            ]
        },
        {
            xtype:'chart',
            margin:'5 10 10 10',
            cls:'x-dashboard-box',
            width:'100%',
            height:500,
            label:{content:'趋势',visible:false}
        },
        {
            xtype:'chart',
            margin:'5 5 10 10',
            cls:'x-dashboard-box',
            width:'50%',
            height:500,
            label:'交存'
        },
        {
            xtype:'chart',
            margin:'5 10 10 5',
            cls:'x-dashboard-box',
            width:'50%',
            height:500,
            label:'使用'
        },
        {
            xtype:'chart',
            margin:'5 5 10 10',
            cls:'x-dashboard-box',
            width:'50%',
            height:500,
            label:'增值'
        },
        {
            xtype:'chart',
            margin:'5 10 10 5',
            cls:'x-dashboard-box',
            width:'50%',
            height:500,
            label:'派息'
        }
    ],
    tabTitle:'概况',
    /*
    * */
    constructor: function constructor (config) {
        config = config || {};
        this.apply(config);
    },
    load:function load() {

        var me  = this;
        this.callParent();


        setTimeout(function () {
            me.initialChart();
        },1000);

        return this;
    },
    /*
    *
    * */
    initialChart:function initialChart() {

        var me = this;

        setTimeout(function () {

            Rsd.app.getService('Report.Global').requestJson(null,function (data) {
                if($empty(data))
                {
                    return;
                }
                //console.log(data);
                var _data = data.data;

                var option1 = {
                    title : {
                        /* text: '资金总额',
                         subtext: 'DEMO'*/
                    },
                    tooltip : {
                        trigger: 'axis'
                    },
                    legend: {
                        data:[]
                    },
                    toolbox: {
                        show : false,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {show: true, type: ['line', 'bar']},
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : false,
                    xAxis : [
                        {
                            type : 'category',   boundaryGap: true,
                            show:false,
                            data: _data['NianYue']
                        }
                    ],
                    yAxis : [
                        {
                            show:false,
                            type : 'value'
                        }
                    ],
                    series : [
                        {
                            name:'余额',
                            type:'line',
                            /*itemStyle: {
                                normal: {
                                    label: {
                                        show: false
                                    },
                                    labelLine: {
                                        show: false
                                    }
                                } ,
                                emphasis: {
                                    label: {
                                        show: true,
                                        position: 'outer'
                                    },
                                    labelLine: {
                                        show: true,
                                        lineStyle: {
                                            color: 'red'
                                        }
                                    }
                                }
                            },*/
                            data: [3440.00,5323.00,7450.00,9112.00,10732.90,12823.00,14754.00,16323.80,19432.90,23623.80,24789.00,26689.00]
                        }

                    ]
                };
                var option2 = {
                    title : {
                    },
                    tooltip : {
                        trigger: 'axis'
                    },
                    legend: {
                        data:[]
                    },
                    toolbox: {
                        show : false,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {show: true, type: ['line', 'bar']},
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : true,
                    xAxis : [
                        {
                            type : 'category',   boundaryGap: true,
                            show:false,
                            data: _data['NianYue']
                        }
                    ],
                    yAxis : [
                        {
                            show:false,
                            type : 'value'
                        }
                    ],
                    series : [
                        {
                            name:'交存',
                            type:'bar',
                            color:'rgba(45, 26, 206, 0.9)',
                            data: _data['JiaoCun']


                        }
                    ]
                };
                var option3 = {
                    title : {
                    },
                    tooltip : {
                        trigger: 'axis'
                    },
                    legend: {
                        data:[]
                    },
                    toolbox: {
                        show : false,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {show: true, type: ['line', 'bar']},
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : true,
                    xAxis : [
                        {
                            type : 'category',   boundaryGap: true,
                            show:false,
                            data: _data['NianYue']
                        }
                    ],
                    yAxis : [
                        {

                            show:false,
                            type : 'value'
                        }
                    ],
                    series : [

                        {
                            name:'增值',
                            type:'bar',
                            color:'green',
                            data: [4000,2300,5000,1200,3290,2300,5400,2380,3290,2380,8900,3250]

                        }
                    ]
                };
                var option4 = {
                    title : {
                    },
                    tooltip : {
                        trigger: 'axis'
                    },
                    legend: {
                        data:[]
                    },
                    toolbox: {
                        show : false,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {show: true, type: ['line', 'bar']},
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : true,
                    xAxis : [
                        {
                            show:false,
                            type : 'category',   boundaryGap: true,
                            data: _data['NianYue']
                        }
                    ],
                    yAxis : [
                        {
                            show:false,
                            type : 'value'
                        }
                    ],
                    series : [

                        {
                            name:'使用',
                            type:'bar',
                            color:'rgba(64, 81, 131, 0.74902)',
                            data: [4000,2300,5000,1200,3290,2300,5400,2380,3290,2380,8900,3250],

                        }
                    ]
                };

                me.items[0].items[0].loadData(option1);
                me.items[0].items[1].loadData(option2);
                me.items[0].items[2].loadData(option3);
                me.items[0].items[3].loadData(option4);

                var option = {
                    title : {
                        text: '资金趋势图',
                        subtext: 'DEMO'
                    },
                    tooltip : {
                        trigger: 'axis'
                    },
                    legend: {
                        data:['余额','缴存','使用']
                    },
                    toolbox: {
                        show : true,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {show: true, type: ['line', 'bar']},
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : true,
                    xAxis : [
                        {
                            type : 'category',   boundaryGap: true,
                            data: _data['NianYue']
                        }
                    ],
                    yAxis : [
                        {
                            type : 'value'
                        }
                    ],
                    series : [
                        {
                            name:'余额',
                            type:'line',
                            data: [3440.00,4323.00,5450.00,6112.00,7732.90,9823.00,10754.00,12323.80,13432.90,13623.80,14789.00,15689.00],
                            markPoint : {
                                data : [
                                    {type : 'max', name: '最大值'},
                                    {type : 'min', name: '最小值'}
                                ]
                            }
                        },
                        {
                            name:'缴存',
                            type:'bar',
                            data: [5000,3300,8000,3200,2290,9300,7400,6380,4290,3380,9900,8500],
                            markPoint : {
                                data : [
                                    {type : 'max', name: '最大值'},
                                    {type : 'min', name: '最小值'}
                                ]
                            },
                            markLine : {
                                data : [
                                    {type : 'average', name : '平均值'}
                                ]
                            }
                        },
                        {
                            name:'使用',
                            type:'bar',
                            data: [4000,2300,5000,1200,3290,2300,5400,2380,3290,2380,8900,3250],
                            markPoint : {
                                data : [
                                    {type : 'max', name: '最大值'},
                                    {type : 'min', name: '最小值'}
                                ]
                            },
                            markLine : {
                                data : [
                                    {type : 'average', name : '平均值'}
                                ]
                            }
                        }
                    ]
                };
                me.items[1].loadData(option);


                option = {
                    title : {
                        text: '资金来源分布',
                        subtext: 'DEMO',
                        x:'center'
                    },
                    tooltip : {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    legend: {
                        orient : 'vertical',
                        x : 'left',
                        data:['住房','电梯、消防设备','增值']
                    },
                    toolbox: {
                        show : true,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {
                                show: true,
                                type: ['pie', 'funnel'],
                                option: {
                                    funnel: {
                                        x: '25%',
                                        width: '50%',
                                        funnelAlign: 'left',
                                        max: 1548
                                    }
                                }
                            },
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : true,
                    series : [
                        {
                            name:'交存',
                            type:'pie',
                            radius : '55%',
                            center: ['50%', '60%'],
                            data:[
                                {value:135000, name:'电梯、消防设备'},
                                {value:3451548, name:'住房'},
                                {value:800, name:'增值'}
                            ]
                        }
                    ]
                };
                me.items[2].loadData(option);

                option = {
                    title : {
                        text: '资金使用',
                        subtext: 'DEMO',
                        x:'center'
                    },
                    tooltip : {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    legend: {
                        orient : 'vertical',
                        x : 'left',
                        data:['申请中','待划拨','已划拨','已分摊']
                    },
                    toolbox: {
                        show : true,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {
                                show: true,
                                type: ['pie', 'funnel'],
                                option: {
                                    funnel: {
                                        x: '25%',
                                        width: '50%',
                                        funnelAlign: 'left',
                                        max: 1548
                                    }
                                }
                            },
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : true,
                    series : [
                        {
                            name:'使用',
                            type:'pie',
                            radius : '55%',
                            center: ['50%', '60%'],
                            data:[
                                {value:15000, name:'申请中'},
                                {value:21548, name:'待划拨'},
                                {value:64800, name:'已划拨'},
                                {value:94800, name:'已分摊'}
                            ]
                        }
                    ]
                };
                me.items[3].loadData(option);

                option = {
                    title : {
                        text: '资金增值',
                        subtext: 'DEMO',
                        x:'center'
                    },
                    tooltip : {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    legend: {
                        orient : 'vertical',
                        x : 'left',
                        data:['活期利息','定存利息']
                    },
                    toolbox: {
                        show : true,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {
                                show: true,
                                type: ['pie', 'funnel'],
                                option: {
                                    funnel: {
                                        x: '25%',
                                        width: '50%',
                                        funnelAlign: 'left',
                                        max: 1548
                                    }
                                }
                            },
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : true,
                    series : [
                        {
                            name:'资金增值',
                            type:'pie',
                            radius : '55%',
                            center: ['50%', '60%'],
                            data:[
                                {value:135000, name:'活期利息'},
                                {value:3451548, name:'定存利息'}
                            ]
                        }
                    ]
                };
                me.items[4].loadData(option);

                option = {
                    title : {
                        text: '增值派息',
                        subtext: 'DEMO',
                        x:'center'
                    },
                    tooltip : {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    legend: {
                        orient : 'vertical',
                        x : 'left',
                        data:['已派息','未派息','其他支出']
                    },
                    toolbox: {
                        show : true,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {
                                show: true,
                                type: ['pie', 'funnel'],
                                option: {
                                    funnel: {
                                        x: '25%',
                                        width: '50%',
                                        funnelAlign: 'left',
                                        max: 1548
                                    }
                                }
                            },
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : true,
                    series : [
                        {
                            name:'交存',
                            type:'pie',
                            radius : '55%',
                            center: ['50%', '60%'],
                            data:[
                                {value:135000, name:'未派息'},
                                {value:3451548, name:'已派息'},
                                {value:548, name:'其他支出'}
                            ]
                        }
                    ]
                };
                me.items[5].loadData(option);

            });

        },100);

        return this;

    }
});